#include<stdio.h>
int main()
{
    int a, b, c, d, e, g;
    for (g = 1; g <= 100000; g++) {

        if (g / 10 == 0) {
            a = g;
            if (a == g) {
                printf("%d ", g);
            }
            continue;
        }
        if (g / 100 == 0)
        {
            a = g % 10;
            b = g / 10;
            if (a * a + b * b == g) {
                printf("%d ", g);
            }
            continue;
        }
        if (g / 1000 == 0)
        {
            a = g % 10;
            b = g / 10 % 10;
            c = g / 100;
            if (a * a * a + b * b * b + c * c * c == g) {
                printf("%d ", g);
            }
            continue;
        }
        if (g / 10000 == 0)
        {
            a = g % 10;
            b = g / 10 % 10;
            c = g / 100 % 10;
            d = g / 1000;
            if (a * a * a * a + b * b * b * b + c * c * c * c + d * d * d * d == g) {
                printf("%d ", g);
            }
            continue;
        }
        if (g / 100000 == 0)
        {
            a = g % 10;
            b = g / 10 % 10;
            c = g / 100 % 10;
            d = g / 1000 % 10;
            e = g / 10000;
            if (a * a * a * a * a + b * b * b * b * b + c * c * c * c * c + d * d * d * d * d + e * e * e * e * e == g) {
                printf("%d ", g);
            }
            continue;
        }
    }
    return 0;
}